package org.eclipse.mylyn.rememberthemilk.ui.editors;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.mylyn.rememberthemilk.core.RTMAttributeMapper.Attribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

public class RtmTaskTagPart extends AbstractTaskEditorPart {
	
	public RtmTaskTagPart() {
		setPartName("Tags");
	}

	@Override
	public void createControl(Composite parent, FormToolkit toolkit) {
		Section section = createSection(parent, toolkit, true);
		
		Composite composite = toolkit.createComposite(section);
		
		GridLayout layout = new GridLayout();
		layout.verticalSpacing = 5;
		composite.setLayout(layout);
		
		Label tagsLabel = new Label(composite, SWT.LEFT);
		tagsLabel.setText("Use a comma seperated list to set the tags");
		
		AbstractAttributeEditor tagEditor = createAttributeEditor(getTaskData().getRoot().getAttribute(Attribute.TAGS.getRTMKey()));
		if (tagEditor != null) {
			tagEditor.createControl(composite, toolkit);

			GridDataFactory.fillDefaults().hint(500, SWT.DEFAULT).grab(true, false).applyTo(tagEditor.getControl());
			getTaskEditorPage().getAttributeEditorToolkit().adapt(tagEditor);
		}
		
//		toolkit.paintBordersFor(composite);
		section.setClient(composite);
		setSection(toolkit, section);
	}

}
